package com.meepo.framework.design.helper

import android.content.Context
import android.graphics.Color
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import java.lang.Exception

object ColorHelper {

    @JvmStatic
    fun parseColor(colorString: String): Int {
        try {
            return Color.parseColor(colorString)
        } catch (e: Exception) {
        }

        return 0
    }


    fun strColor(context: Context, @ColorRes colorId: Int): String {
        return String.format("#%06X", ContextCompat.getColor(context, colorId))
    }

    fun colorInt(context: Context, @ColorRes colorId: Int): Int {
        return ContextCompat.getColor(context, colorId)
    }

    fun getColorStrByInt(@ColorInt colorInt: Int): String {
        return String.format("#%06X", colorInt)
    }
}